package com.akka.akkaacotr;

import akka.actor.ActorSystem;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author LHL
 * @date 2019/6/13
 */
@Configuration
public class ApplicationConfiguration {
    @Autowired
    private ApplicationContext applicationContext;
    @Autowired
    private SpringExtension springExtension;

    @Bean
    public ActorSystem actorSystem(){
        ActorSystem system = ActorSystem.create("system",akkaConfig());
        springExtension.initialize(applicationContext);
        return system;
    }
    @Bean
    public Config akkaConfig(){
        return ConfigFactory.
                load();
    }

}
